home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d13 / pj9_3.arc / PBBI.BAS < prev    next >
BASIC Source File  |  1991-10-07  |  4KB  |  84 lines

  1. '***********************************************************************
  2. '                               PBBI.BAS                               *
  3. '   PBBI is a program to update the declaration header file PB.BI,     *
  4. ' used with Microsoft BASIC compiler (BC) version 7, for a new or      *
  5. ' replacement library module.   Usually, it is run by the $$$.BAT file *
  6. ' produced by DOLIB.EXE.  However, it can be run as a standalone       *
  7. ' program if the file PB.BI is in the default directory.  When run as  *
  8. ' a standalone, call with: "PBBI <filespec>" where <filespec> is a     *
  9. ' complete specification (including drive and path) to the module      *
  10. ' source file.                                                         *
  11. '    If the source file contains coded SUB or FUNCTION declaration     *
  12. ' statements (enclosed in square brackets), the PB.BI header file will *
  13. ' be updated; the previous version of PB.BI will be renamed to PB.BKE. *
  14. ' If the source file does not contain coded declaration statements,    *
  15. ' the new PB.BI will be identical to PB.BKE.  An existing SUB or       *
  16. ' FUNCTION declaration statement in the PB.BI file for the same        *
  17. ' procedure name will be replaced.  A new declaration will be added.   *
  18. '----------------------------------------------------------------------*
  19. '               Written by M. L. Lesser, April 14, 1990                *
  20. '                 Compiled with BC v. 7.1, switch "/O"                 *
  21. '      Linked to NOCOM, NOLPT and NOFLTIN with switches "/E/NOE"       *
  22. '***********************************************************************
  23.  
  24.     DEFINT I-N
  25.     DEFSTR D,F,P,T
  26.     DIM DECLARATIONS(32), FILENAME, I, J, K, N, PROCNAME(32), T, TEXT
  27.  
  28.     OPEN COMMAND$ FOR INPUT AS #1 LEN=5120            'Source code file
  29.     LET N = 0
  30. ' Search source file for coded embedded procedure declarations:
  31.     WHILE NOT EOF(1)
  32.         LINE INPUT #1, TEXT                     
  33.         LET I = INSTR(UCASE$(TEXT),"[DECLARE")
  34.         IF I THEN                                      'Found one
  35.             LET J = INSTR(TEXT,"]")
  36.             LET DECLARATIONS(N) = RTRIM$(MID$(TEXT,I+1,J-I-1))
  37.             LET N = N + 1
  38.         END IF
  39.     WEND
  40.     LET N = N - 1                       'Index of last used array member
  41.     CLOSE #1
  42. ' Parse for procname (second token after "declare").  May end with
  43. '  either a <SP> or a "(", or be the last token in the declaration.
  44.     LET T = "%&!#@$"                    'Data type symbols
  45.     FOR I = 0 TO N
  46.         LET TEXT = LTRIM$(MID$(DECLARATIONS(I),8))
  47.         LET TEXT = LTRIM$(MID$(TEXT,INSTR(TEXT," ") + 1))
  48.         LET J = INSTR(TEXT," "): K = INSTR(TEXT,"(")
  49.         IF J = 0 AND K = 0 THEN
  50.             PROCNAME(I) = TEXT
  51.         ELSEIF J = 0 AND K <> 0 THEN
  52.             LET PROCNAME(I) = LEFT$(TEXT,K-1)
  53.         ELSEIF J <> 0 AND K = 0 THEN
  54.             LET PROCNAME(I) = LEFT$(TEXT,J-1)
  55.         ELSEIF J < K THEN
  56.             LET PROCNAME(I) = LEFT$(TEXT,J-1)
  57.         ELSE
  58.             LET PROCNAME(I) = LEFT$(TEXT,K-1)
  59.         END IF
  60. ' Delete any trailing type designation symbol:
  61.         IF INSTR(T,RIGHT$(PROCNAME(I),1)) THEN
  62.             LET PROCNAME(I) = LEFT$(PROCNAME(I),LEN(PROCNAME(I)) - 1)
  63.         END IF
  64.     NEXT I
  65. ' Update PB.BI file, renaming old version to PB.BKE:
  66.     IF DIR$("PB.BKE") <> "" THEN KILL "PB.BKE"  'Delete old back file
  67.     NAME "PB.BI" AS "PB.BKE"
  68.     OPEN "PB.BKE" FOR INPUT AS #1 LEN=1024
  69.     OPEN "PB.BI" FOR OUTPUT AS #2 LEN=1024
  70.     WHILE NOT EOF(1)
  71.         LINE INPUT #1, TEXT
  72.         FOR I = 0 TO N
  73.             IF INSTR(UCASE$(TEXT),UCASE$(PROCNAME(I))) THEN GOTO FOUNDIT
  74.         NEXT I
  75.         PRINT #2, TEXT                  'If not in this module
  76. FOUNDIT:
  77.     WEND
  78. ' Add new declarations at end of PB.BI:
  79.     FOR I = 0 TO N
  80.         PRINT #2, DECLARATIONS(I)
  81.     NEXT I
  82.     CLOSE
  83. END
  84.